package com.smallrig.mall.template.huawei;

import java.util.Map;

public class 座位安排 {

    static int[] nums = new int[]{1,1,0,1,2,1,0};

    public static void main(String[] args) {

        System.out.println(solve());
    }
    public static int solve(){
        //left[i]代表i左边有多少连续1
        int[] left = new int[nums.length];
        left[0] = 0;
        for(int i=1;i<nums.length;i++){
            if(nums[i-1]==1){
                left[i] = left[i-1]+1;
            }
        }

        //right[i]代表i右边有多少连续1
        int[] right = new int[nums.length];
        right[nums.length-1] = 0;
        for(int i=nums.length-2;i>=0;i--){
            if(nums[i+1]==1){
                right[i] = right[i+1]+1;
            }
        }

        int cnt = 0;
        for(int i=0;i<nums.length;i++){
            if(nums[i]==0){
                cnt = Math.max(cnt,left[i]+right[i]);
            }
        }
        return cnt;
    }
}
